import { defineEventHandler } from 'h3';

export default defineEventHandler(async () => {
  // 模拟自定义状态定义数据
  const statusDefinitions = [
    {
      id: '1',
      name: '待审核',
      code: 'PENDING_REVIEW',
      description: '资源等待审核状态',
      color: '#faad14',
      icon: 'ant-design:clock-circle-outlined',
      isInitial: true,
      isFinal: false,
      allowedTransitions: ['APPROVED', 'REJECTED'],
      metadata: {
        requiresApproval: true,
        autoTransition: false,
      },
    },
    {
      id: '2',
      name: '已审核',
      code: 'APPROVED',
      description: '资源审核通过状态',
      color: '#52c41a',
      icon: 'ant-design:check-circle-outlined',
      isInitial: false,
      isFinal: false,
      allowedTransitions: ['ACTIVE', 'SUSPENDED'],
      metadata: {
        requiresApproval: false,
        autoTransition: true,
      },
    },
    {
      id: '3',
      name: '已拒绝',
      code: 'REJECTED',
      description: '资源审核拒绝状态',
      color: '#ff4d4f',
      icon: 'ant-design:close-circle-outlined',
      isInitial: false,
      isFinal: true,
      allowedTransitions: [],
      metadata: {
        requiresApproval: false,
        autoTransition: false,
      },
    },
    {
      id: '4',
      name: '已激活',
      code: 'ACTIVE',
      description: '资源已激活状态',
      color: '#1890ff',
      icon: 'ant-design:play-circle-outlined',
      isInitial: false,
      isFinal: false,
      allowedTransitions: ['SUSPENDED', 'ARCHIVED'],
      metadata: {
        requiresApproval: false,
        autoTransition: false,
      },
    },
    {
      id: '5',
      name: '已暂停',
      code: 'SUSPENDED',
      description: '资源暂停状态',
      color: '#722ed1',
      icon: 'ant-design:pause-circle-outlined',
      isInitial: false,
      isFinal: false,
      allowedTransitions: ['ACTIVE', 'ARCHIVED'],
      metadata: {
        requiresApproval: false,
        autoTransition: false,
      },
    },
    {
      id: '6',
      name: '已归档',
      code: 'ARCHIVED',
      description: '资源归档状态',
      color: '#8c8c8c',
      icon: 'ant-design:inbox-outlined',
      isInitial: false,
      isFinal: true,
      allowedTransitions: [],
      metadata: {
        requiresApproval: false,
        autoTransition: false,
      },
    },
  ];

  return {
    code: 0,
    data: statusDefinitions,
    msg: '获取自定义状态定义成功',
  };
});
